package com.sparkseries.controller;

import com.sparkseries.common.util.domain.Result;
import com.sparkseries.service.LogoutService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户退出
 */
@RestController
@RequestMapping("logout")
@Tag(name = "用户退出")
public class LogoutController {
    @Resource
    private LogoutService logoutService;

    /**
     * 退出
     * @param token 用户token
     * @return 默认响应类
     */
    @GetMapping
    @Operation(summary = "退出")
    @Parameter(name = "token", required = true)
    @PreAuthorize("")
    public Result<?> logout(@RequestParam("token") String token) {
        return logoutService.logout(token);
    }
}
